package com.feicheng.common.advice;

import com.feicheng.common.constant.Constant;
import org.springframework.stereotype.Component;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

@Component
public class AdminLoginInterceptor extends CommonHandlerInterceptor {

    @Override
    public boolean preHandle(
            HttpServletRequest request,
            HttpServletResponse response, Object handler)
            throws Exception {
        HttpSession session = request.getSession();

        if (session.getAttribute(Constant.RESULT.CURRENT) == null) {
            authFailOutput(response);
            return false;
        }

        return true;
    }
}
